package com.tarena.practice.manage.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tarena.practice.manage.mapper.CategoriesMapper;
import com.tarena.practice.manage.pojo.Categories;

@Service
public class CategoriesService {

	@Autowired
	private CategoriesMapper categoriesMapper;
	
	@Autowired
	private TopicService topicService;
	
	/**
	 * 获取分类的详细信息列表  一级分类|二级分类|...|底级分类
	 * @return
	 */
	public List<Categories> queryCategoryDetail() {
		Map<String, Object> map = new HashMap<>();
		List<Categories> categories = categoriesMapper.queryIsParent();
		for (int i = 0; i < categories.size(); i++) {
			Categories category = categories.get(i);
			category.setCategoryName(topicService.getCategoryDetail(category.getCategoryName(), category));
		}
		
		return categories;
	}

}
